﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Globalization;
using Google.GData.YouTube;
using Resources;
using System.Threading;
using System.Net.Mail;
using System.Net;
using System.IO;
using Google.GData.Client;
using Google.GData.Photos;

public partial class _Page : System.Web.UI.Page
{
    public string TrendWord { get; set; }

    public string CompanyName { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {

        foreach (string key in Request.QueryString)
        {
            switch (key.ToLower())
            {
                case "symbol": this.TrendWord = System.Web.HttpUtility.UrlDecode(Request.QueryString[key]); break;
                case "company": this.CompanyName = System.Web.HttpUtility.UrlDecode(Request.QueryString[key]); break;
            }


        }
        if (!IsPostBack)
        {

            MainWebContent.SearchPhrase = this.TrendWord;
            this.Title = GenerateTitle();
        }
        if (!string.IsNullOrEmpty(this.TrendWord))
        {
            bool PageAllowed = GoogleHelper.CheckKeyWordAllowed(this.TrendWord);
            if (!PageAllowed)
            {
                Response.Redirect("default.aspx");
                Response.Write("this query is not allowed on this page");
            }
        }




        //Set the title

    }

    private string GenerateTitle()
    {
        StringBuilder result = new StringBuilder();
        //result.Append("The Web About ");
        result.Append(this.TrendWord);
        result.Append(" ");
        result.Append(this.CompanyName);
        result.Append(" - Latest ");
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-us");
        //result.Append(DateTime.Now.ToLongDateString());
        result.Append(" Financial News, Blogs, Videos And Pictures Dated ");
        result.Append(DateTime.Now.ToString("MMMM yyyy"));
        string actualResult = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(result.ToString());
        return actualResult;
    }



}

